package org.bai.miaoshaproject.error;

/**
 * ClassName BusinessException
 *
 * @author Bai
 * @version 1.0
 * @date 2019/5/27 0027 下午 23:40
 **/
public class BusinessException extends Exception implements CommonError {

    private CommonError commonError;


    /**
     * 直接使用EmBusinessError的传参来构造
     * @param commonError {@link CommonError}
     */
    public BusinessException(CommonError commonError){
        super();
        this.commonError = commonError;
    }

    public BusinessException(CommonError commonError, String errMsg){
        super();
        this.commonError = commonError;
        this.commonError.setErrorMsg(errMsg);
    }

    @Override
    public int getErrorCode() {
        return this.commonError.getErrorCode();
    }

    @Override
    public String getErrorMsg() {
        return this.commonError.getErrorMsg();
    }

    @Override
    public CommonError setErrorMsg(String errorMsg) {
        this.commonError.setErrorMsg(errorMsg);
        return this;
    }
}
